<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script> -->
    <script src="./js/vue.js"></script>
    <title>组件的嵌套</title>
  </head>
  <body>
    <div id="root">
   
    </div>

    <script>

     //创建hello组件
    const hello={
        template:`
        <h1>欢迎来到组件嵌套页面</h1>
        `,
    };

      const student = Vue.extend({
        template: `
        <div>
        <h2>{{studentName}}</h2>
        <h2>{{age}}</h2>
        </div>
        `,
        data() {
          return {
            studentName: "李彤康",
            age: "22",
          };
        },
      });

      const school = Vue.extend({
        template: `
        <div>
        <h2>{{schoolName}}</h2>
        <h2>{{address}}</h2>
        <student/>
        </div>
        `,
        data() {
          return {
            schoolName: "尚硅谷",
            address: "北京昌平",
          };
        },

        components:{
            student
        }
      });
 
    //创建根组件去管理这些组件

    const app={
        template:`
        <div>
        <hello/>
        <school/>
        </div>
        `,
     components:{
        hello,
        school
     }
    }
      new Vue({
        template:`
        <div>
            <app/>
            </div>
        `,
        el: "#root",
        data: {},
        methods: {},
        components:{
           app
        }
      });
    </script>
  </body>
</html>
